package net.jxtz.jxtzos.landtax;

import com.alibaba.excel.annotation.ExcelProperty;
import net.jxtz.jxtzos.entity.landtax.Residential;
import net.jxtz.jxtzos.entity.landtax.dto.ListHeader;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 * @author a123
 */
public class TableHeader {

    public static List<ListHeader> getListHeader(){
        Class<Residential> residentialClass = Residential.class;
        Field[] declaredFields = residentialClass.getDeclaredFields();
        List<ListHeader> list = new ArrayList<>();
        for (int i = 0; i < declaredFields.length; i++) {
            if (declaredFields[i].isAnnotationPresent(ExcelProperty.class)){
                String name = declaredFields[i].getName();
                ExcelProperty annotation = declaredFields[i].getAnnotation(ExcelProperty.class);
                String[] value = annotation.value();
                list.add(new ListHeader(i, value[0], name, true));
            }

        }
        return list;
    }

}
